#include "stdafx.h"
#include "CppUnitTest.h"
#include "..\RenderingTechniques\Maths.h"
#include "..\RenderingTechniques\OctTreee.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTests
{		
	TEST_CLASS(UnitTest1)
	{
	public:
		
		TEST_METHOD(TestMethod)
		{
			Triangle<float> *triangle = new Triangle<float>(Vec3<float>(5.0),Vec3<float>(6.0),Vec3<float>(7.0));
			Assert::AreEqual(triangle->vertA.x, triangle->vertA.x);
		}

		/*
		Test for the intersection of a cube and a ray
		Test trinagle
		*/

		TEST_METHOD(BoundingBoxFunctionaing)
		{
			Vec3<float> minPoint(1,1,1);
			Vec3<float> maxPoint(5,5,5);

			BoundingBox<float> *testBoudningBox = new BoundingBox<float>(minPoint, maxPoint);

			Vec3<float> origin(0,0,0);
			Vec3<float> direction(2,2,2);
			direction.normalize();

			bool output = testBoudningBox->CheckIntersection(origin, direction);

			Assert::AreEqual(output, true);
		}

		TEST_METHOD(TriangleRayIntersectrion)
		{
			Vec3<float> vertA(1,1,1), vertB(3,1,1), vertC(2,3,1);
			Triangle<float> *testTrinagle = new Triangle<float>(vertA, vertB, vertC);
			Vec3<float> orig(0,0,0);
			Vec3<float> direc(2,2,1);
			direc.normalize();
			bool output = testTrinagle->CheckRayIntersection(orig, direc);
			Assert::AreEqual(output, true);
		}

		TEST_METHOD(InitOctTree)
		{
			bool itWorks = false;

			try
			{

				OctTree<float> *testTree = new OctTree<float>();
				itWorks = true;
			}
			catch(exception ex)
			{
				itWorks = false;
			}


			Assert::AreEqual(itWorks, true);

			
		}

	};
}